const path = require('path');

const htmlWebpackPlugin = require('html-webpack-plugin');

const {VueLoaderPlugin} = require('vue-loader');

module.exports={
	entry: path.join(__dirname,'./src/index.js'),
	output: {
		filename: 'bundle.js',
		path: path.resolve(__dirname,'dist')
	},
	plugins:[   //【配置插件的节点】
		new htmlWebpackPlugin({
			template:path.join(__dirname,'./src/index.html'),
			filename:'index.html'
		}),
		new VueLoaderPlugin()
	],
    module:{  //【loader配置节点】
	    rules:[
	    	//【匹配CSS的loader】
            {test:/\.css$/,use:['style-loader','css-loader']},
            //【匹配less的loader】
            {test:/\.less/,use:['style-loader','css-loader','less-loader']},
            //【匹配sass的loader】
            {test:/\.sass/,use:['style-loader','css-loader','sass-loader']},
			//【配置背景图片url的loader】
            {test:/\.bmp|jpg|jpeg|png|gif$/,use:'url-loader?limit=25443&name=[hash:3]-[name].[ext]'},
            //【配置字体图片url的loader】
            {test:/\.eot|svg|ttf|woff|woff2$/,use:'url-loader'},
			//【配置可以读取ES6新语法特性的loader】
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
            //【配置可以读取vue结尾的loader】
            {test:/\.vue$/,use:'vue-loader'}
        ]
    }
};